# include "src/core/datetime.h"
#define CSTR(qstr) (qstr.toUtf8().constData())
-#define CSTRE_(qstr, enc) (enc->fromUnicode(qstr).constData())
-#define CSTRE(qstr) (CSTRE_(qstr, codec))
/*
* Amazingly, this constant is not specified in the standard...
#define WAYPT_GET(wpt,member,def) ((wpt->wpt_flags.member) ? (wpt->member) : (def))
#define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0
#define WAYPT_HAS(wpt,member) (wpt->wpt_flags.member)
+
+#define CSTRc(qstr) (qstr.toLatin1().constData())
+// Maybe the XmlGeneric string callback really shouldn't have a type
+// of its own; this was a crutch during the move from char* to QString.
+// It's "just" a search and replace to make it go away, but it might
+// be convenient to overload some day.
+typedef const QString& xg_string;
+
/*
* This is a waypoint, as stored in the GPSR. It tries to not
* cater to any specific model or protocol. Anything that needs to
* be truncated, edited, or otherwise trimmed should be done on the
* way to the target.
*/
-#if NEW_STRINGS
- typedef QString String;
- #define CSTRc(qstr) (qstr.toLatin1().constData())
- typedef const QString& xg_string;
-#else
- #define CSTRc(qstr) (qstr)
- typedef char* String;
- typedef const char* xg_string;
-#endif
-
class Waypoint
{
private:
* minimum length for shortname is 6 characters for NMEA units,
* 8 for Magellan and 10 for Vista. These are only guidelines.
*/
- String shortname;
+ QString shortname;
/*
* description is typically a human readable description of the
* waypoint. It may be used as a comment field in some receivers.
* These are probably under 40 bytes, but that's only a guideline.
*/
- String description;
+ QString description;
/*
* notes are relatively long - over 100 characters - prose associated
* with the above. Unlike shortname and description, these are never
* used to compute anything else and are strictly "passed through".
* Few formats support this.
*/
- String notes;
+ QString notes;
/* TODO: UrlLink should probably move to a "real" class of its own.
*/
public:
queue Q; /* Link onto parent list. */
queue waypoint_list; /* List of child waypoints */
- String rte_name;
- String rte_desc;
+ QString rte_name;
+ QString rte_desc;
QString rte_url;
int rte_num;
int rte_waypt_ct; /* # waypoints in waypoint list */
#define mkshort( a, b) MKSHORT(a,b,__FILE__, __LINE__)
#define mkshort_new_handle() MKSHORT_NEW_HANDLE(__FILE__,__LINE__)
#endif
-String mkshort_from_wpt(short_handle h, const Waypoint* wpt);
+QString mkshort_from_wpt(short_handle h, const Waypoint* wpt);
void mkshort_del_handle(short_handle* h);
void setshort_length(short_handle, int n);
void setshort_badchars(short_handle, const char*);
void* xmalloc(size_t size);
void* xrealloc(void* p, size_t s);
void xfree(const void* mem);
-#ifndef NEW_STRINGS
-char* xstrdup(const char* s);
-#endif
char* xstrdup(const QString& s);
char* xstrndup(const char* s, size_t n);
char* xstrndupt(const char* s, size_t n);
void rtrim(char* s);
char* lrtrim(char* s);
int xasprintf(char** strp, const char* fmt, ...) PRINTFLIKE(2, 3);
-int xasprintf(String* strp, const char* fmt, ...) PRINTFLIKE(2, 3);
+int xasprintf(QString* strp, const char* fmt, ...) PRINTFLIKE(2, 3);
int xvasprintf(char** strp, const char* fmt, va_list ap);
char* strupper(char* src);
char* strlower(char* src);
static void
tlog3a_xgcb_version(xg_string args, const QXmlStreamAttributes*)
{
-#if NEW_STRINGS
if (args != "1") {
-#else
- if (strcmp(args, "1") != 0) {
-#endif
fatal(MYNAME ": Unsupported file version '%s'!\n", CSTRc(args));
}
}
ez_disp(const Waypoint* wpt)
{
gbfputc('W', file_out);
-#if NEW_STRINGS
if (!wpt->shortname.isEmpty()) {
-#else
- if (wpt->shortname) {
-#endif
gbfputc(1, file_out);
gbfputpstr(wpt->shortname, file_out);
}
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
-#else
- if (wpt->description) {
-#endif
gbfputc(3, file_out);
gbfputpstr(wpt->description, file_out);
}
gbfputc(0x64, file_out);
gbfputdbl(wpt->longitude, file_out);
-#if NEW_STRINGS
if (!wpt->notes.isEmpty()) {
-#else
- if (wpt->notes) {
-#endif
gbfputc(5, file_out);
gbfputpstr(wpt->notes, file_out);
}
char* ident;
char obuf[256];
-#if NEW_STRINGS
QString src;
if (!wpt->description.isEmpty()) {
src = wpt->description;
if (!wpt->notes.isEmpty()) {
src = wpt->notes;
}
-#else
- char *src = NULL;
- if (wpt->description) {
- src = wpt->description;
- }
- if (wpt->notes) {
- src = wpt->notes;
- }
-#endif
/*
* mkshort will do collision detection and namespace
// If we were explictly given a comment from GPX, use that.
// This logic really is horrible and needs to be untangled.
-#if NEW_STRINGS
if (!wpt->description.isEmpty() &&
-#else
- if (wpt->description &&
-#endif
global_opts.smart_names && !wpt->gc_data->diff) {
memcpy(tx_waylist[i]->cmnt, CSTRc(wpt->description), strlen(CSTRc(wpt->description)));
} else {
{
(*cur_tx_routelist_entry)->rte_num = rte->rte_num;
(*cur_tx_routelist_entry)->isrte = 1;
-#if NEW_STRINGS
if (!rte->rte_name.isEmpty()) {
-#else
- if (rte->rte_name) {
-#endif
strncpy((*cur_tx_routelist_entry)->rte_ident, CSTRc(rte->rte_name),
sizeof((*cur_tx_routelist_entry)->rte_ident));
}
// This was strncpy(rte->ident, wpt->shortname, sizeof(rte->ident));
char* d;
d = rte->ident;
-#if NEW_STRINGS
for (int idx = 0; idx < wpt->shortname.length(); idx++) {
int c = wpt->shortname[idx].toLatin1();
-#else
- for (char* s = wpt->shortname; *s; s++) {
- int c = *s;
-#endif
if (receiver_must_upper && isalpha(c)) {
c = toupper(c);
}
track_hdr_pr(const route_head* trk_head)
{
(*cur_tx_tracklist_entry)->ishdr = gpsTrue;
-#if NEW_STRINGS
if (!trk_head->rte_name.isEmpty()) {
-#else
- if (trk_head->rte_name) {
-#endif
strncpy((*cur_tx_tracklist_entry)->trk_ident, CSTRc(trk_head->rte_name), sizeof((*cur_tx_tracklist_entry)->trk_ident));
(*cur_tx_tracklist_entry)->trk_ident[sizeof((*cur_tx_tracklist_entry)->trk_ident)-1] = 0;
} else {
(*cur_tx_tracklist_entry)->lon = wpt->longitude;
(*cur_tx_tracklist_entry)->alt = (wpt->altitude != unknown_alt) ? wpt->altitude : 1e25;
(*cur_tx_tracklist_entry)->Time = wpt->GetCreationTime().toTime_t();;
-#if NEW_STRINGS
if (!wpt->shortname.isEmpty()) {
-#else
- if (wpt->shortname) {
-#endif
strncpy((*cur_tx_tracklist_entry)->trk_ident, CSTRc(wpt->shortname), sizeof((*cur_tx_tracklist_entry)->trk_ident));
(*cur_tx_tracklist_entry)->trk_ident[sizeof((*cur_tx_tracklist_entry)->trk_ident)-1] = 0;
}
void type_s(xg_string args, const QXmlStreamAttributes*)
{
-#if NEW_STRINGS
type = args.compare("GPSData");
-#else
- type = strcmp(args, "GPSData");
-#endif
}
void device_s(xg_string args, const QXmlStreamAttributes*)
if (type) {
return;
}
-#if NEW_STRINGS
if ((args == "OutputFromUnit")) {
-#else
- if (0 == strcmp(args, "OutputFromUnit")) {
-#endif
xasprintf(&my_gdx_info->from_device.path, "%s%c%s",
mountpoint, GB_PATHSEP, path);
my_gdx_info->from_device.basename = xstrdup(base);
my_gdx_info->from_device.path,
my_gdx_info->from_device.basename,
my_gdx_info->from_device.extension);
-#if NEW_STRINGS
} if ((args == "InputToUnit")) {
-#else
- } else if (0 == strcmp(args, "InputToUnit")) {
-#endif
xasprintf(&my_gdx_info->to_device.path, "%s%c%s",
mountpoint, GB_PATHSEP, path);
my_gdx_info->to_device.basename = xstrdup(base);
(void) gbfgetint16(fin); /* ? always 1 ? */
(void) gbfgetc(fin); /* seems to 1 when extra options present */
-#if NEW_STRINGS
- wpt->shortname = gpi_read_string("Shortname");
-#else
wpt->shortname = gpi_read_string("Shortname");
-#endif
while (gbftell(fin) < (gbsize_t)(pos + sz - 4)) {
int tag = gbfgetint32(fin);
break;
}
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
-#else
- if (wpt->description) {
-#endif
wpt->notes = str;
} else {
-#if NEW_STRINGS
wpt->description = str;
-#else
- wpt->description = str;
-#endif
}
break;
{
const Waypoint* wa = (Waypoint*) a;
const Waypoint* wb = (Waypoint*) b;
-#if NEW_STRINGS
return wa->shortname.compare(wb->shortname);
-#else
- return strcmp(wa->shortname, wb->shortname);
-#endif
}
static char
return s1.compare(s2);
}
-#if !NEW_STRINGS
-static char
-compare_strings(const char* s1, const char* s2)
-{
- if (s1 == s2) {
- return 0;
- } else if (s1) {
- if (s2) {
- return strcmp(s1, s2);
- } else {
- return 1;
- }
- } else {
- return 1;
- }
-}
-#endif
-
-
static writer_data_t*
wdata_alloc()
{
res += 12; /* tag/sz/sub-sz */
res += 19; /* poi fixed size */
-#if NEW_STRINGS
res += wpt->shortname.length();
-#else
- res += strlen(wpt->shortname);
-#endif
if (! opt_hide_bitmap) {
res += 10; /* tag(4) */
}
wpt = new Waypoint(*ref);
if (*opt_unique == '1') {
-#if NEW_STRINGS
wpt->shortname = mkshort(short_h, wpt->shortname);
-#else
- char* str = mkshort(short_h, wpt->shortname);
- xfree(wpt->shortname);
- wpt->shortname = str;
-#endif
}
wdata_add_wpt(wdata, wpt);
{
const Waypoint* wa = *(Waypoint**)a;
const Waypoint* wb = *(Waypoint**)b;
-#if NEW_STRINGS
return wa->shortname.compare(wb->shortname, Qt::CaseInsensitive);
-#else
- return case_ignore_strcmp(QString::fromLatin1(wa->shortname), QString::fromLatin1(wb->shortname));
-#endif
}
if (! valid) {
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n",
-#if NEW_STRINGS
wpt->shortname.isEmpty() ? "Waypoint" : CSTR(wpt->shortname),
-#else
- wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint",
-#endif
pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0),
gt_get_mps_grid_longname(grid_index, MYNAME));
}
wpt_type = gt_waypt_class_names[0];
}
-#if NEW_STRINGS
gbfprintf(fout, "Waypoint\t%s\t", CSTRc(wpt->shortname));
-#else
- gbfprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? CSTRc(wpt->shortname) : "");
-#endif
if (wpt_class <= gt_waypt_class_airport_ndb) {
QString temp = wpt->notes;
if (temp.isEmpty()) {
-#if NEW_STRINGS
if (wpt->description != wpt->shortname) {
-#else
- if (wpt->description && (strcmp(wpt->description, wpt->shortname) != 0)) {
-#endif
temp = wpt->description;
} else {
temp = "";
gtxt_flags.route_header_written = 1;
gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[route_header]);
}
-#if NEW_STRINGS
print_string("\r\nRoute\t%s\t", current_trk->rte_name);
-#else
- print_string("\r\nRoute\t%s\t", current_trk->rte_name ? CSTRc(current_trk->rte_name) : "");
-#endif
print_distance(cur_info->length, 0, 1, 0);
print_course(cur_info->first_wpt, cur_info->last_wpt);
gbfprintf(fout, "\t%d waypoints\t", cur_info->count);
gtxt_flags.track_header_written = 1;
gbfprintf(fout, "\r\n\r\nHeader\t%s\r\n", headers[track_header]);
}
-#if NEW_STRINGS
print_string("\r\nTrack\t%s\t", current_trk->rte_name);
-#else
- print_string("\r\nTrack\t%s\t", current_trk->rte_name ? CSTRc(current_trk->rte_name) : "");
-#endif
print_date_and_time(cur_info->start, 0);
print_date_and_time(cur_info->time, 1);
print_distance(cur_info->length, 0, 1, 0);
int gbfputc(int c, gbfile* file);
int gbfputs(const char* s, gbfile* file);
int gbfputs(const QString& s, gbfile* file);
-#if NEW_STRINGS
-typedef QString String;
-#endif
int gbfwrite(const void* buf, const gbsize_t size, const gbsize_t members, gbfile* file);
int gbfflush(gbfile* file);
static short_handle desc_handle;
#define MYNAME "googledir"
-#define MY_CBUF 4096
static xg_callback goog_points, goog_poly_e;
static xg_callback goog_instr;
decode_goog64(const QByteArray& str, int& pos)
{
long result = 0;
- unsigned char c = 0;
unsigned char shift = 0;
if (pos >= str.size()) {
return 0;
}
+ unsigned char c;
do {
- c = (unsigned char)str.at(pos++)-'?';
- result |= (c & 31)<<shift;
+ c = str.at(pos++) - '?';
+ result |= (c & 31) << shift;
shift += 5;
} while (c & ~31);
const QByteArray qbstr = encoded_points.toUtf8();
route_head* routehead = route_head_alloc();
-#if NEW_STRINGS
if (args == "overview_polyline") {
-#else
- if (strcmp(args, "overview_polyline") == 0) {
-#endif
routehead->rte_name = "overview";
routehead->rte_desc = "Overview";
} else {
} else {
utf_string utf;
utf.is_html = 1;
- utf.utfstring = /*QString::fromUtf8*/(instructions);
- char *s = strip_html(&utf);
- routehead->rte_desc = s;
- xfree(s);
+ utf.utfstring = instructions;
+ routehead->rte_desc = strip_html(&utf);
instructions = QString();
}
}
#define MYNAME "GPX"
-#define MY_CBUF_SZ 4096
#ifndef CREATOR_NAME_URL
# define CREATOR_NAME_URL "GPSBabel - http://www.gpsbabel.org"
#endif
static void detect_pres_track(const route_head* rh)
{
-#if NEW_STRINGS
if (rh->rte_name.startsWith(PRESTRKNAME)) {
-#else
- if (rh->rte_name && strncmp(rh->rte_name, PRESTRKNAME, 6) == 0) {
-#endif
head = rh;
}
}
static void detect_gnss_track(const route_head* rh)
{
-#if NEW_STRINGS
if (rh->rte_name.startsWith(GNSSTRKNAME)) {
-#else
- if (rh->rte_name && strncmp(rh->rte_name, GNSSTRKNAME, 6) == 0) {
-#endif
head = rh;
}
}
}
// Find other track with the most waypoints
if (rh->rte_waypt_ct > max_waypt_ct &&
-#if NEW_STRINGS
(rh->rte_name.isEmpty() ||
(!rh->rte_name.startsWith(PRESTRKNAME) &&
!rh->rte_name.startsWith(GNSSTRKNAME)))) {
-#else
- (!rh->rte_name ||
- (strncmp(rh->rte_name, PRESTRKNAME, 6) != 0 &&
- strncmp(rh->rte_name, GNSSTRKNAME, 6) != 0))) {
-#endif
head = rh;
max_waypt_ct = rh->rte_waypt_ct;
}
static void wr_task_wpt_name(const Waypoint* wpt, const char* alt_name)
{
gbfprintf(file_out, "C%s%s\r\n", latlon2str(wpt),
-#if NEW_STRINGS
!wpt->description.isEmpty() ? CSTR(wpt->description) : !wpt->shortname.isEmpty() ? CSTR(wpt->shortname) : alt_name);
-#else
- wpt->description ? wpt->description : wpt->shortname ? wpt->shortname : alt_name);
-#endif
}
static void wr_task_hdr(const route_head* rte)
// See if the takeoff and landing waypoints are there or if we need to
// generate them.
wpt = (Waypoint*) QUEUE_LAST(&rte->waypoint_list);
-#if NEW_STRINGS
if (wpt->shortname.startsWith("LANDING")) {
-#else
- if (wpt->shortname && strncmp(wpt->shortname, "LANDING", 6) == 0) {
-#endif
num_tps--;
}
wpt = (Waypoint*) QUEUE_FIRST(&rte->waypoint_list);
-#if NEW_STRINGS
if (wpt->shortname.startsWith("TAKEOFF")) {
-#else
- if (wpt->shortname && strncmp(wpt->shortname, "TAKEOFF", 6) == 0) {
-#endif
have_takeoff = 1;
num_tps--;
}
fatal(MYNAME ": Bad task route timestamp\n");
}
-#if NEW_STRINGS
if (!rte->rte_desc.isEmpty()) {
// desc will be something like "IGCDATE160701: 500KTri"
sscanf(CSTR(rte->rte_desc), DATEMAGIC "%6[0-9]: %s", flight_date, task_desc);
}
-#else
- if (rte->rte_desc) {
- sscanf(rte->rte_desc, DATEMAGIC "%6[0-9]: %s", flight_date, task_desc);
- }
-#endif
gbfprintf(file_out, "C%s%s%s%04u%02u%s\r\n", date2str(tm),
tod2str(tm), flight_date, task_num++, num_tps, task_desc);
static void
ignr_nb_etapes(xg_string args, const QXmlStreamAttributes* attrv)
{
-#if NEW_STRINGS
xmlpoints = args.toInt();
-#else
- xmlpoints = atoi(args);
-#endif
}
static void
static void
ignr_etape_pos(xg_string args, const QXmlStreamAttributes* attrv)
{
-#if NEW_STRINGS
ignr_xml_error((wpt == NULL) || (args.isEmpty()));
-#else
- ignr_xml_error((wpt == NULL) || (args == NULL));
-#endif
if (2 != sscanf(CSTRc(args), "%lf,%lf", &wpt->latitude, &wpt->longitude)) {
fatal(MYNAME ": Invalid coordinates \"%s\"!\n", CSTRc(args));
iktobj_type(xg_string args, const QXmlStreamAttributes*)
{
ikt_object_end();
-#if NEW_STRINGS
switch (args.toInt()) {
-#else
- switch (atoi(args)) {
-#endif
case 0:
waypt = new Waypoint;
break;
timen += interval) {
Waypoint* wpt_new = new Waypoint(*wpt);
wpt_new->SetCreationTime(timen);
-#if NEW_STRINGS
wpt_new->shortname = QString();
wpt_new->description = QString();
-#else
- if (wpt_new->shortname) {
- xfree(wpt_new->shortname);
- }
- if (wpt_new->description) {
- xfree(wpt_new->description);
- }
- wpt_new->shortname = wpt_new->description = NULL;
-#endif
+
linepart(lat1, lon1,
wpt->latitude, wpt->longitude,
(double)(timen-time1)/
Waypoint* wpt_new = new Waypoint(*wpt);
wpt_new->SetCreationTime(distn/curdist*
(wpt->creation_time.toTime_t() - time1) + time1);
-#if NEW_STRINGS
wpt_new->shortname = QString();
wpt_new->description = QString();
-#else
- if (wpt_new->shortname) {
- xfree(wpt_new->shortname);
- }
- if (wpt_new->description) {
- xfree(wpt_new->description);
- }
- wpt_new->shortname = wpt_new->description = NULL;
-#endif
linepart(lat1, lon1,
wpt->latitude, wpt->longitude,
distn/curdist,
same_points(const Waypoint* A, const Waypoint* B)
{
return ( /* !!! We are case-sensitive !!! */
-#if NEW_STRINGS
(A->shortname == B->shortname) &&
-#else
- (strcmp(A->shortname, B->shortname) == 0) &&
-#endif
(A->latitude == B->latitude) &&
(A->longitude == B->longitude));
}
QString placeddate = maggeo_fmtdate(waypointp->creation_time);
QString lfounddate = maggeo_fmtdate(waypointp->gc_data->last_found);
QString cname = mkshort(desc_handle,
-#if NEW_STRINGS
waypointp->notes.isEmpty() ? waypointp->description : waypointp->notes);
-#else
- QString(waypointp->notes ? waypointp->notes : waypointp->description));
-#endif
placer = waypointp->gc_data->placer;
/*
+ NULL (1) + prox(9) + display(4) + colour(4) + symbol(4) + city(sz) +
state(sz) + facility(sz) + unknown2(1) + depth(9) + unknown3(7) */
/* -1 as reclen is interpreted from zero meaning a reclength of one */
-#if NEW_STRINGS
if (!wpt->notes.isEmpty()) {
-#else
- if (wpt->notes) {
-#endif
reclen += strlen(CSTRc(wpt->notes));
}
} else {
gbfputc(1, mps_file);
gbfputdbl(mps_altitude, mps_file);
}
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
-#else
- if (wpt->description) {
-#endif
gbfputs(ascii_description, mps_file);
}
gbfwrite(zbuf, 1, 1, mps_file); /* NULL termination */
* As above, but arg list is a waypoint so we can centralize
* the code that considers the alternate sources.
*/
-String
+QString
mkshort_from_wpt(short_handle h, const Waypoint* wpt)
{
/* This probably came from a Groundspeak Pocket Query
* more stuff than should be in any one field...
*/
if (wpt->gc_data->diff && wpt->gc_data->terr &&
-#if NEW_STRINGS
!wpt->notes.isEmpty()) {
-#else
- wpt->notes && wpt->notes[0]) {
-#endif
return mkshort(h, wpt->notes);
}
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
-#else
- if (wpt->description) {
-#endif
return mkshort(h, wpt->description);
}
-#if NEW_STRINGS
if (!wpt->notes.isEmpty()) {
-#else
- if (wpt->notes) {
-#endif
return mkshort(h, wpt->notes);
}
mmo_write_wpt_cb(const Waypoint* wpt)
{
char* str;
- String cx;
+ QString cx;
int objid;
time_t time;
int icon = 0;
WPNC.wp_data.North = (int32_t)lat;
WPNC.wp_data.East = (int32_t)lon;
- String s;
+ QString s;
if (reorder_wp) {
sprintf(temp_short_name, "A%03d", current_wp_ix);
s = temp_short_name;
Waypoint* wpt_a = ((const htable_t*)a)->wpt;
Waypoint* wpt_b = ((const htable_t*)b)->wpt;
-#if NEW_STRINGS
return wpt_a->description.compare(wpt_b->description);
-#else
- return strcmp(wpt_a->description, wpt_b->description);
-#endif
}
}
{
char obuf[200];
double lat,lon;
- String s;
+ QString s;
int cksum;
lat = degrees2ddmm(wpt->latitude);
gbfflush(file_out);
gb_sleep(sleepus);
}
-#if NEW_STRINGS
-#else
- xfree(s);
-#endif
-
}
void
same_points(const Waypoint* A, const Waypoint* B)
{
return ( /* !!! We are case-sensitive !!! */
-#if NEW_STRINGS
(A->shortname == B->shortname) &&
-#else
- (strcmp(A->shortname, B->shortname) == 0) &&
-#endif
(A->latitude == B->latitude) &&
(A->longitude == B->longitude));
}
{
const Waypoint* wa = *(Waypoint**)a;
const Waypoint* wb = *(Waypoint**)b;
-#if NEW_STRINGS
return wa->shortname.compare(wb->shortname);
-#else
- return strcmp(wa->shortname, wb->shortname);
-#endif
}
static void
return;
}
-#if NEW_STRINGS
if (rte_name.isEmpty() && !trk->rte_name.isEmpty()) {
-#else
- if (rte_name.isEmpty() && trk->rte_name) {
-#endif
rte_name = trk->rte_name;
rte_desc = trk->rte_desc;
}
snprintf(cdate, sizeof(cdate), "%02d/%02d/%04d", tm.tm_mon, tm.tm_mday, tm.tm_year);
snprintf(ctime, sizeof(ctime), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
- String sn;
+ QString sn;
switch (what) {
case STM_WAYPT:
sn = mkshort(short_h, wpt->shortname);
}
gbfprintf(fout, "WP,D,%s,", CSTRc(sn));
-#if NEW_STRINGS
-#else
- xfree(sn);
-#endif
break;
case STM_TRKPT:
if (version < 2) { /* keep the old behaviour */
wpt_tmp->notes = wpt_tmp->description;
-#if NEW_STRINGS
wpt_tmp->description = QString();
-#else
- wpt_tmp->description = NULL;
-#endif
}
wpt_tmp->notes = fix_notes(wpt_tmp->shortname, wpt_tmp->notes);
{
int icon = 1; /* default to "flag" */
int colour = 255; /*default to red */
-#if NEW_STRINGS
QString shortname;
QString description;
if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
if (!wpt->description.isEmpty()) {
-#else
- char* shortname = NULL;
- char* description = NULL;
- if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
- if (wpt->description) {
-#endif
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
shortname = csv_stringclean(wpt->shortname, ",\"");
}
-#if NEW_STRINGS
if (wpt->description.isEmpty()) {
if (!shortname.isEmpty()) {
-#else
- if (! wpt->description) {
- if (shortname) {
-#endif
description = csv_stringclean(shortname, ",\"");
} else {
description = xstrdup("");
l ? l : ""
);
-#if NEW_STRINGS
-#else
- if (description) {
- xfree(description);
- }
- if (shortname) {
- xfree(shortname);
- }
-#endif
if (l) {
xfree(l);
}
* and a shortname
*/
-#if NEW_STRINGS
if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
if (!wpt->description.isEmpty()) {
-#else
- if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
- if (wpt->description) {
-#endif
if (global_opts.synthesize_shortnames) {
shortname = mkshort_from_wpt(mkshort_handle, wpt);
} else {
} else {
shortname = wpt->shortname;
}
-#if NEW_STRINGS
if (wpt->description.isEmpty()) {
-#else
- if (! wpt->description) {
-#endif
if (!shortname.isEmpty()) {
description = shortname;
} else {
{
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area of grid \"%s\"!\n",
-#if NEW_STRINGS
wpt->shortname.isEmpty() ? "Waypoint" : CSTR(wpt->shortname),
-#else
- wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint",
-#endif
pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0),
gt_get_mps_grid_longname(unicsv_grid_idx, MYNAME));
}
if (!wpt->icon_descr.isNull()) {
gb_setbit(&unicsv_outp_flags, fld_symbol);
}
-#if NEW_STRINGS
if (!wpt->description.isEmpty() && shortname != wpt->description) {
-#else
- if (wpt->description && *wpt->description && shortname != wpt->description) {
-#endif
gb_setbit(&unicsv_outp_flags, fld_description);
}
-#if NEW_STRINGS
if (!wpt->notes.isEmpty() && shortname != wpt->notes) {
if ((wpt->description.isEmpty()) || (wpt->description != wpt->notes)) {
-#else
- if (wpt->notes && *wpt->notes && shortname != wpt->notes) {
- if ((! wpt->description) || (strcmp(wpt->description, wpt->notes) != 0)) {
-#endif
gb_setbit(&unicsv_outp_flags, fld_notes);
}
}
double usec = fmod(1000000*seconds+0.5,1000000);
wpt_tmp->SetCreationTime(mkgmtime(&tmStruct), lround(usec/1000.0));
-#if NEW_STRINGS
wpt_tmp->shortname = QString().sprintf("WP%04d", ++serial);
-#else
- wpt_tmp->shortname = (char*) xcalloc(16,1);
- snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial);
-#endif
WAYPT_SET(wpt_tmp, speed, KNOTS_TO_MPS(speed)); /* meters per second */
WAYPT_SET(wpt_tmp, course, course);
}
printposn(wpt->latitude,1);
printposn(wpt->longitude,0);
-#if NEW_STRINGS
if (!wpt->description.isEmpty()) {
-#else
- if (wpt->description) {
-#endif
printf("%s/%s",
global_opts.synthesize_shortnames ?
qPrintable(mkshort(mkshort_handle, wpt->description)) :
altitude(unknown_alt),
depth(0),
proximity(0),
-#if !NEW_STRINGS
- shortname(NULL),
- description(NULL),
- notes(NULL),
-#endif
- // url_link_list_(),
- // wpt_flags(),
- // icon_descr(),
- // creation_time(),
route_priority(0),
hdop(0),
vdop(0),
#define xfreez(p) { if (p) xfree(p); p=0; }
#define MYNAME "wfff_xml"
-#define MY_CBUF 4096
static xg_callback wfff_s, wfff_e;
static xg_callback wfff_wep, wfff_mac, wfff_type;
// thus we will not process the EndElement case as we will issue a readNext first.
// does a caller ever expect to be able to use both a cb_cdata and a
// cb_end callback?
-#if NEW_STRINGS
cb(c, NULL);
-#else
- cb(CSTRE(c), NULL);
-#endif
current_tag.chop(reader.qualifiedName().length() + 1);
}
break;
cb = xml_tbl_lookup(current_tag, cb_end);
if (cb) {
-#if NEW_STRINGS
cb(reader.name().toString(), NULL);
-#else
- cb(CSTRE(reader.name().toString()), NULL);
-#endif
}
current_tag.chop(reader.qualifiedName().length() + 1);
break;
{
gbfprintf(fout, "#####\n");
fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n",
-#if NEW_STRINGS
wpt->shortname.isEmpty() ? "Waypoint" : CSTRc(wpt->shortname),
-#else
- wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint",
-#endif
pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0),
gt_get_mps_grid_longname(grid_swiss, MYNAME));
}